/**
 * Copyright (C), 2024, Y2 T205
 * FileName: ch01_05
 * Author: Lenovo
 * Date: 2024-01-15 15:43
 * Description:
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */


package com.example.multithreading;


/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author Lenovo
 * @create 2024-01-15
 * @since 1.0.0
 */

import org.springframework.boot.test.context.SpringBootTest;

/**
 * 买票任务
 */
@SpringBootTest
public class ch01_06 implements Runnable {



    private static final int MAX =20;

    private static int index=1;




    @Override
    public void run(){
        while(index<=MAX){
            System.out.println("柜台:"+Thread.currentThread()+"当前的号码为:"+(index++));
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

    public static void main(String[] args){
        final ch01_06 task =new ch01_06();

        Thread obj1 =new Thread(task,"一号柜台");
        obj1.start();

        Thread obj2 =new Thread(task,"二号柜台");
        obj2.start();

        Thread obj3 =new Thread(task,"三号柜台");
        obj3.start();

        Thread obj4 =new Thread(task,"四号柜台");
        obj4.start();
    }




}
